//
//  ViewController.swift
//  YYPBlankView
//
//  Created by YYPan on 2018/5/18.
//  Copyright © 2018年 YYPan. All rights reserved.
//

import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

	private lazy var tableView: UITableView = {
		let table = UITableView(frame: self.view.bounds)
		table.delegate = self
		table.dataSource = self
		table.rowHeight = 50
		return table
	}()
	
	private lazy var dataSources: [String] = {
		let array = ["没有网络","没有数据","没有搜索结果"]
		return array
	}()
	
	override func viewDidLoad() {
		super.viewDidLoad()
		view.addSubview(tableView)
	}

	override func didReceiveMemoryWarning() {
		super.didReceiveMemoryWarning()
		// Dispose of any resources that can be recreated.
	}

	func numberOfSections(in tableView: UITableView) -> Int {
		return 1
	}
	
	func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
		return dataSources.count
	}
	
	func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
		let cell = UITableViewCell()
		cell.textLabel?.text = dataSources[indexPath.row]
		return cell
	}
	
	func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
		tableView.deselectRow(at: indexPath, animated: true)
		let viewController = BlankViewController()
		viewController.type = dataSources[indexPath.row]
		navigationController?.pushViewController(viewController, animated: true)
	}
}

